import unittest
from Public import HTMLTestReportCNPy3
import os
import time
dir=os.path.abspath(os.curdir)
result = dir+"\\Result\\"
from TestCase.newBusiness import newBusiness

#创建测试集123
def CreateSuite():
    suite = unittest.TestSuite()
    # case = unittest.TestLoader().loadTestsFromTestCase(Test_Index)
    # case1 =unittest.TestLoader().loadTestsFromTestCase(Test_Login)
    case2 =unittest.TestLoader().loadTestsFromTestCase(newBusiness)
    suite.addTest(case2)
    #suite.addTest(case1)
    return suite

#生成报告
def run():
    suite = CreateSuite()
    day = time.strftime('%Y-%m-%d',time.localtime(time.time()))
    rep_dir = result+day
    if not os.path.exists(rep_dir):
        os.makedirs(rep_dir)
    filename=rep_dir+'\\'+"result.html"
    f = open(filename,'wb')
    runner=HTMLTestReportCNPy3.HTMLTestRunner(stream=f,title='测试报告',description='第一次运行测试报告')
    runner.run(suite)
    f.close()
run()